package com.huawei.appmarket.service.appmgr.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import huawei.widget.HwTextView;
import o.epv;
import o.ewm.d;

public class FixedTextLinearLayout extends LinearLayout {
    private int ˊ = 8;
    private int ˋ = 8;
    private TextView ˎ;
    private Context ˏ;
    private TextView ॱ;

    public FixedTextLinearLayout(Context context) {
        super(context);
        this.ˏ = context;
        ˋ();
    }

    public FixedTextLinearLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ˏ = context;
        ˋ();
    }

    public FixedTextLinearLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˏ = context;
        ˋ();
    }

    private void ˋ() {
        if (this.ˎ == null) {
            this.ˎ = new TextView(this.ˏ);
            this.ˎ.setSingleLine(true);
        }
        if (this.ॱ == null) {
            this.ॱ = new TextView(this.ˏ);
            this.ॱ.setSingleLine(true);
        }
    }

    public float ˊ(Context context, float f) {
        return f / context.getResources().getDisplayMetrics().scaledDensity;
    }

    public void ˏ() {
        if (getChildCount() == 2 && (getChildAt(0) instanceof HwTextView) && (getChildAt(1) instanceof HwTextView)) {
            HwTextView hwTextView = (HwTextView) getChildAt(0);
            HwTextView hwTextView2 = (HwTextView) getChildAt(1);
            if (hwTextView2.getVisibility() != 0) {
                hwTextView.setAutoTextSize(ˊ(this.ˏ, (float) this.ˏ.getResources().getDimensionPixelSize(d.ꞌ)));
            }
            this.ˋ = hwTextView2.getVisibility();
            if (this.ˊ == 8 && this.ˋ == 0) {
                int ˋ = ˋ(hwTextView, hwTextView2);
                this.ˎ.setTextSize(ˊ(this.ˏ, (float) this.ˏ.getResources().getDimensionPixelSize(d.ꞌ)));
                this.ˎ.setLayoutParams(new LayoutParams(-2, -2));
                this.ˎ.measure(-2, -2);
                int measuredHeight = this.ˎ.getMeasuredHeight();
                this.ॱ.setTextSize(ˊ(this.ˏ, (float) this.ˏ.getResources().getDimensionPixelSize(d.ﾟ)));
                this.ॱ.setLayoutParams(new LayoutParams(-2, -2));
                this.ॱ.measure(-2, -2);
                int measuredHeight2 = this.ॱ.getMeasuredHeight();
                float textSize = this.ˎ.getTextSize();
                float textSize2 = this.ॱ.getTextSize();
                float ॱ = (float) epv.ॱ(this.ˏ, 1);
                while (measuredHeight2 + measuredHeight > ˋ) {
                    textSize -= ॱ;
                    textSize2 -= ॱ;
                    this.ˎ.setTextSize(ˊ(this.ˏ, textSize));
                    this.ˎ.measure(-2, -2);
                    measuredHeight = this.ˎ.getMeasuredHeight();
                    this.ॱ.setTextSize(ˊ(this.ˏ, textSize2));
                    this.ॱ.measure(-2, -2);
                    measuredHeight2 = this.ॱ.getMeasuredHeight();
                }
                hwTextView.setAutoTextSize(ˊ(this.ˏ, textSize));
                hwTextView2.setAutoTextSize(ˊ(this.ˏ, textSize2));
                return;
            }
            this.ˊ = this.ˋ;
        }
    }

    private int ˋ(HwTextView hwTextView, HwTextView hwTextView2) {
        int i;
        int dimensionPixelSize = this.ˏ.getResources().getDimensionPixelSize(d.ʻˊ);
        LayoutParams layoutParams = (LayoutParams) hwTextView.getLayoutParams();
        LayoutParams layoutParams2 = (LayoutParams) hwTextView2.getLayoutParams();
        if (layoutParams != null) {
            i = layoutParams.bottomMargin + (0 + layoutParams.topMargin);
        } else {
            i = 0;
        }
        if (layoutParams2 != null) {
            i = (i + layoutParams2.topMargin) + layoutParams2.bottomMargin;
        }
        return dimensionPixelSize - i;
    }
}
